<?php
/*
	Copyright (c) 2005 Mr. Brian Burton - brian@dynamoeffects.com

	Released under the GNU General Public License

    Copyright (C) 2007  PayPal Inc.

*/


/**
 * the requires
 */
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

  // -- webMS Modification --
  // Check if osCommerce environment is already loaded
  if (defined( '_OSCOMMERCE_LOADED' )) {
    if (!DB_SHARED) {
      // Reconnect to osCommerce Database
      tep_db_connect() or die('Unable to connect to database server!');
    }
    // Load osCommerce Globals for Boxes
    global $category_links, $languages_id, $catID, $catID_array, $current_category_id;
    global $request_type, $lng, $cart, $currencies, $language, $navigation, $breadcrumb;
  } else {
    // Load osCommerce Environment for the First Time
    require('components/'.$option.'/includes/application_top.php');
  }
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_EC_PROCESS);
require(DIR_WS_CLASSES . 'payment.php');
/**
 * unset any paypal error so we can collect cleanly a new one
 */
if (tep_session_is_registered('paypal_error')) tep_session_unregister('paypal_error');
/**
 * see if we were sent a request to clear the session
 * for paypal
 */
if (isset($_REQUEST['clearSess'])) {
    /**
     * unset the paypal information
     */
    unset($_SESSION['paypal_ec_temp']);
    unset($_SESSION['paypal_ec_payer_id']);
    unset($_SESSION['paypal_ec_payer_info']);
    tep_session_unregister('paypal_ec_temp');
	tep_session_unregister('paypal_ec_payer_id');
	tep_session_unregister('paypal_ec_payer_info');
}
/**
 * see if paypal_wpp is enabled
 */
if(tep_paypal_wpp_enabled()){
    /**
  	 * init the payment object for paypal_wpp
  	 */
    $payment_modules = new payment('paypal_wpp');
    /**
     * set the payment, if their hitting ec_process.php then we
     * know the payment method selected right now.
     */
    tep_session_register('payment');
    $_SESSION['payment'] = 'paypal_wpp';
    /**
     * check to see if we have info back from paypal.
     */
    if(!tep_session_is_registered('paypal_ec_token') || isset($_GET['clearSess'])) {
    	/**
    	 * This push on the first step in the paypal wpp payment
    	 * module.  We have not went to paypal's website yet in
    	 * order to grab a token at this time.  This will send the
    	 * user on to paypals website for EC
    	 */
    	$payment_modules->ec_step1();
    }else{
      	/**
      	 * This will push on the second step of the paypal wpp
      	 * payment module, as we already have a paypal express
      	 * checkout token at this point.
      	 */
    	$payment_modules->ec_step2();
    }
}
?>
<html>
Processing...
</html>